﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Cfg;
using NHibernate;

namespace Mpu.NHibernateDataModelProvider
{
    public class NHibernateFactory
    {
        public static NHibernateFactory Current = new NHibernateFactory();

        private readonly ISessionFactory SessionFactory;
        public readonly Configuration Configuration;

        public ISession OpenSession()
        {
            var session = SessionFactory.OpenSession();
            return session;
        }

        private NHibernateFactory()
        {
            this.Configuration = new Configuration();
            this.Configuration.Configure();
            this.SessionFactory = this.Configuration.BuildSessionFactory();
        }
    }
}
